package View;

import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JTable;
import javax.swing.JButton;

import java.awt.Font;
import java.io.Serializable;
/** This class create new GUI for searching customers to update their details */
public class UpdateCustomerView extends JFrame  implements Serializable {

	/**required  fields and buttons */
	private static final long serialVersionUID = 42L;
	JTextField IdField;
	 JTable table;
	 JButton SearchBtn;
	 JButton BackBtn;
	
	 /** default and only constructor */
	public UpdateCustomerView() {
		getContentPane().setLayout(null);
		setResizable(false);

		this.setLocationRelativeTo(null); 
		this.setTitle("Search Customer");
		this.setBounds(450, 200,436, 265);
		JLabel lblCustumerId = new JLabel("CustomerID");
		lblCustumerId.setFont(new Font("Tahoma", Font.BOLD, 13));
		lblCustumerId.setBounds(91, 75, 109, 20);
		getContentPane().add(lblCustumerId);
		
		IdField = new JTextField();
		IdField.setBounds(215, 76, 135, 20);
		getContentPane().add(IdField);
		IdField.setColumns(10);
		
		SearchBtn = new JButton("Search");
		SearchBtn.setFont(new Font("Tahoma", Font.BOLD, 15));
		SearchBtn.setBounds(262, 169, 135, 28);
		getContentPane().add(SearchBtn);
		

	
		BackBtn = new JButton("Back");
		BackBtn.setFont(new Font("Tahoma", Font.BOLD, 15));
		BackBtn.setBounds(59, 169, 135, 28);
		getContentPane().add(BackBtn);
		
		JLabel lblSearchCustomerId = new JLabel("Search Customer ID in order to update ");
		lblSearchCustomerId.setFont(new Font("Tahoma", Font.BOLD, 13));
		lblSearchCustomerId.setBounds(104, 27, 284, 20);
		getContentPane().add(lblSearchCustomerId);
	
		
		
		
	}
	/**
	 * add action listener to any button in the window
	 * @param actionListener
	 */
	public void updateCustomerListener(ActionListener actionListener){
		SearchBtn.addActionListener(actionListener);
		BackBtn.addActionListener(actionListener);		
	}
	
	/** show and hide window functions */
	public void showWindow(){
		setVisible(true);
	}
	public void hideWindow(){
		setVisible(false);
	}

	/**
	 * @return button SearchBtn
	 */
	public JButton getSearchBtn()
	{
		return this.SearchBtn;
	}
	/**
	 * @return button BackBtn
	 */
	public JButton getBackBtn()
	{
		return this.BackBtn;
	}
	/**
	 * @return text field IdField
	 */
	public String getID() {
		return IdField.getText();
	}
	
	/** set buttons functions */
	public void  setID(){
		IdField.setText("");
	}
	
	/**clear fields functions */
	public void clearFields(){
		IdField.setText("");		
	}


}
